module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
  const Commodity = app.model.define("commodity", {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    title: { type: STRING(30), allowNull: false },
    desc: { type: STRING, allowNull: false },
    price: { type: INTEGER, allowNull: false },
    image: { type: STRING, allowNull: false },
    flower_language: STRING
  });

  Commodity.associate = function () {
    app.model.Commodity.belongsTo(app.model.Commoditytype, {
      foreignKey: "type_id",
      as: "type"
    });
  };

  return Commodity;
};
